package com.wwinsoft.framework.pojo.workflow;

import java.util.Date;

import org.activiti.engine.task.DelegationState;
import org.activiti.engine.task.Task;

import com.wwinsoft.framework.pojo.UIDisplayInterface;
import com.wwinsoft.modules.utils.DateUtils;

/**
 * @author: Tim Chen
 * @since 1.0
 */
public class TaskBean implements Task,UIDisplayInterface {

    private String id;
    private int revision;

    private String owner;
    private String assignee;

    private String parentTaskId;

    private String name;
    private String description;
    private Date createTime;
    private Date dueDate;

    private String executionId;

    private String processInstanceId;

    private String processDefinitionId;

    private String taskDefinitionKey;

    private boolean isDeleted;

    private String eventName;

    private Integer priority;
    
    private Date startTimeFrom;

    private Date startTimeTo;

    private String  processDefinitionName;
    private String  subject;
    private String  initiator;
    private String initiatorName;
    private String assigneeName;
    private String candidateUser;
    private String initiatorNameLike;
    private String assigneeNameLike;
    private String dueDateFlag;

    public TaskBean() {
        this.startTimeFrom = DateUtils.addDays(new Date(), -7);
        this.startTimeTo = new Date();
    }

    public String getProcessDefinitionName() {
        return processDefinitionName;
    }

    public void setProcessDefinitionName(String processDefinitionName) {
        this.processDefinitionName = processDefinitionName;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public String getInitiator() {
        return initiator;
    }

    public void setInitiator(String initiator) {
        this.initiator = initiator;
    }

    public String getInitiatorName() {
        return initiatorName;
    }

    public void setInitiatorName(String initiatorName) {
        this.initiatorName = initiatorName;
    }

    public String getAssigneeName() {
        return assigneeName;
    }

    public void setAssigneeName(String assigneeName) {
        this.assigneeName = assigneeName;
    }

    public String getCandidateUser() {
        return candidateUser;
    }

    public void setCandidateUser(String candidateUser) {
        this.candidateUser = candidateUser;
    }

    public String getAssignee() {
        return assignee;
    }

    public void setAssignee(String assignee) {
        this.assignee = assignee;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getRevision() {
        return revision;
    }

    public void setRevision(int revision) {
        this.revision = revision;
    }

    public String getOwner() {
        return owner;
    }

    public void setOwner(String owner) {
        this.owner = owner;
    }

    public String getParentTaskId() {
        return parentTaskId;
    }

    public void setParentTaskId(String parentTaskId) {
        this.parentTaskId = parentTaskId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getDueDate() {
        return dueDate;
    }

    public void setDueDate(Date dueDate) {
        this.dueDate = dueDate;
    }

    public String getExecutionId() {
        return executionId;
    }

    public void setExecutionId(String executionId) {
        this.executionId = executionId;
    }

    public String getProcessInstanceId() {
        return processInstanceId;
    }

    public void setProcessInstanceId(String processInstanceId) {
        this.processInstanceId = processInstanceId;
    }

    public String getProcessDefinitionId() {
        return processDefinitionId;
    }

    public void setProcessDefinitionId(String processDefinitionId) {
        this.processDefinitionId = processDefinitionId;
    }

    public String getTaskDefinitionKey() {
        return taskDefinitionKey;
    }

    public void setTaskDefinitionKey(String taskDefinitionKey) {
        this.taskDefinitionKey = taskDefinitionKey;
    }

    public boolean isDeleted() {
        return isDeleted;
    }

    public void setDeleted(boolean deleted) {
        isDeleted = deleted;
    }

    public String getEventName() {
        return eventName;
    }

    public void setEventName(String eventName) {
        this.eventName = eventName;
    }

    @Override
    public int getPriority() {
        return priority==null?0:priority.intValue();
    }

    @Override
    public void setPriority(int priority) {
           this.priority = priority;
    }

    @Override
    public DelegationState getDelegationState() {
        return null;
    }

    @Override
    public void setDelegationState(DelegationState delegationState) {

    }

    @Override
    public void delegate(String userId) {

    }

    public Date getStartTimeFrom() {
        return startTimeFrom;
    }

    public void setStartTimeFrom(Date startTimeFrom) {
        this.startTimeFrom = startTimeFrom;
    }

    public Date getStartTimeTo() {
        return startTimeTo;
    }

    public void setStartTimeTo(Date startTimeTo) {
        this.startTimeTo = startTimeTo;
    }

    public String getInitiatorNameLike() {
        return initiatorNameLike;
    }

    public void setInitiatorNameLike(String initiatorNameLike) {
        this.initiatorNameLike = initiatorNameLike;
    }

    public String getAssigneeNameLike() {
        return assigneeNameLike;
    }

    public void setAssigneeNameLike(String assigneeNameLike) {
        this.assigneeNameLike = assigneeNameLike;
    }

    public String getDueDateFlag() {
        return dueDateFlag;
    }

    public void setDueDateFlag(String dueDateFlag) {
        this.dueDateFlag = dueDateFlag;
    }

    public boolean isDueDateFilter(){
        return  dueDateFlag!=null && dueDateFlag.equals("1");
    }

    @Override
    public boolean isOverDue() {
        return DateUtils.isOverDue(dueDate);
    }
}
